import 'package:flutter/material.dart';
import 'package:niuren_demo/configs/Colors_util.dart';
import 'package:niuren_demo/model/ApiAccountItem_model.dart';
import 'package:niuren_demo/view/text/text_style.dart';

class ApiAccountItem extends StatelessWidget {
  final ApiAccountItem_Model dataModel;

  const ApiAccountItem({Key key, this.dataModel}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border(bottom: BorderSide(width: 1,color: Colors.grey)),
      ),
      
      padding: EdgeInsets.symmetric(horizontal: 20,vertical: 20),
      child: Column(
        children: [
          Row(
            children: [
              Container(
                width: 35,
                height: 35,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(35),
                  image: DecorationImage(
                    image: NetworkImage('${dataModel.imageurl}'),
                  ),
                ),
              ),
              SizedBox(width: 10,),
              Expanded(child: Text_style(
                data: '${dataModel.title}',
              ),),
              Container(
                color: ColorsUtil.hexColor(0xF5F5F5),
                padding: EdgeInsets.symmetric(horizontal: 5,vertical: 3),
                child: Text_style(
                  data: '${dataModel.tip1}',
                  fontSize: 11,
                  color: ColorsUtil.hexColor(0xC0984E),
                ),
              ),
              SizedBox(width: 10,),
              Container(
                color: ColorsUtil.hexColor(0xF5F5F5),
                padding: EdgeInsets.symmetric(horizontal: 5,vertical: 3),
                child: Text_style(
                  data: '${dataModel.tip2}',
                  fontSize: 11,
                  color: ColorsUtil.hexColor(0xC0984E),
                ),
              ),
            ],
          ),
          SizedBox(height: 15,),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              buildthird(dataModel.start,"启动"),
              buildthird(dataModel.yesterday,"昨日"),
              buildthird(dataModel.today,"今日"),
            ],
          ),
          SizedBox(height: 10,),
          builddckc(dataModel.duocang,0x00e48e,dataModel.cc_price1),
          SizedBox(height: 8,),
          builddckc(dataModel.kongcang,0xFF3B30,dataModel.cc_price2),
        ],
      ),
    );
  }

  Widget buildthird(String num,String title){
    return Column(
      children: [
        Text_style(
          data: num,
          fontSize: 18,
        ),
        Text_style(
          data: title,
          fontSize: 12,
          color: ColorsUtil.hexColor(0x8c8c8c),
        ),
      ],
    );
  }
  Widget builddckc(int num,int Color,String price,){
    return Row(
      children: [
        Text("空仓数量：",style: TextStyle(color: ColorsUtil.hexColor(0x8c8c8c)),),
        Expanded(child: Text("$num",style: TextStyle(color: ColorsUtil.hexColor(Color)),),),
        Text("持仓均价：",style: TextStyle(color: ColorsUtil.hexColor(0x8c8c8c)),),
        Text(price,style: TextStyle(color: ColorsUtil.hexColor(Color)),),
      ],
    );
  }
}
